package cn.com.lsy.product.lepao.service.impl;

import cn.com.lsy.product.lepao.model.dao.LpAdminTblMapper;
import cn.com.lsy.product.lepao.model.entities.LpAdminTbl;
import cn.com.lsy.product.lepao.model.entities.LpAdminTblExample;
import cn.com.lsy.product.lepao.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService implements IAdminService {

    @Autowired
    LpAdminTblMapper lpAdminTblMapper;

    @Override
    public LpAdminTbl selectUserInfoById(int userId) {

        return lpAdminTblMapper.selectByPrimaryKey(userId);
    }

    @Override
    public List<LpAdminTbl> selectUserInfoByUsername(String username) {

        LpAdminTblExample example = new LpAdminTblExample();
        example.createCriteria().andUsernameEqualTo(username);

        return lpAdminTblMapper.selectByExample(example);
    }

    @Override
    public boolean updateInfo(LpAdminTbl param) {

        if (lpAdminTblMapper.updateByPrimaryKeySelective(param) > 0) {

            return true;

        } else {

            return false;
        }
    }
}
